package com.wxzhou.wangzhuan.entity;

/**
 * 用户到账方式
 */
public enum PaymentType {
    /**
     * 微信到账
     */
    WEPAY(2, "微信到账"),

    /**
     * 支付宝打款
     */
    ALIPAY(3, "支付宝到账"),

    /**
     * 银行卡到账
     */
    BANK_CARD(4, "银行卡到账");

    private final int code;
    private final String description;

    PaymentType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PaymentType fromCode(int code) {
        for (PaymentType channel : PaymentType.values()) {
            if (channel.getCode() == code) {
                return channel;
            }
        }
        throw new IllegalArgumentException("Unknown withdrawal channel code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }

}
